// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.*;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            bk, aq, j

public class cls_NPullToRefreshListView extends cls_ListView
    implements android.widget.AbsListView.OnScrollListener
{

    public NPullToRefreshListView(Context context)
    {
        super(context);
        n = 0;
        v = 20;
        a(context);
    }

    public NPullToRefreshListView(Context context, AttributeSet attributeset)
    {
        super(context, attributeset);
        n = 0;
        v = 20;
        a(context);
    }

    public NPullToRefreshListView(Context context, AttributeSet attributeset, int i1)
    {
        super(context, attributeset, i1);
        n = 0;
        v = 20;
        a(context);
    }

    static j a(NPullToRefreshListView npulltorefreshlistview)
    {
        return npulltorefreshlistview.f;
    }

    private void a(Context context)
    {
        w = new cls_bk(this);
        p = new RotateAnimation(0F, -180F, 1, 0.5F, 1, 0.5F);
        p.setInterpolator(new LinearInterpolator());
        p.setDuration(250L);
        p.setFillAfter(true);
        q = new RotateAnimation(-180F, 0F, 1, 0.5F, 1, 0.5F);
        q.setInterpolator(new LinearInterpolator());
        q.setDuration(250L);
        q.setFillAfter(true);
        h = (LayoutInflater)context.getSystemService("layout_inflater");
        i = (LinearLayout)h.inflate(0x7f030016, null);
        j = (TextView)i.findViewById(0x7f0d0040);
        k = (ImageView)i.findViewById(0x7f0d003f);
        l = (ProgressBar)i.findViewById(0x7f0d003e);
        m = (TextView)i.findViewById(0x7f0d0041);
        k.setMinimumHeight(50);
        i.setOnClickListener(new cls_aq(this, null));
        s = i.getPaddingTop();
        o = 1;
        addHeaderView(i);
        super.setOnScrollListener(this);
        u = 20;
        setSelection(1);
    }

    private void a(MotionEvent motionevent)
    {
        if(!x) goto _L2; else goto _L1
_L1:
        return;
_L2:
        int i1 = getFirstVisiblePosition();
        Log.v("handleMove", (new StringBuilder()).append("mCurrentScrollState == ").append(n).append(" mRefreshState== ").append(o).append(" firstVisibleItem: ").append(i1).toString());
        if(n == 1 && o != 4)
            if(i1 == 0)
            {
                k.setVisibility(0);
                if((i.getBottom() >= r + u || i.getTop() >= 0) && o != 3)
                {
                    j.setText(0x7f0a01fb);
                    k.clearAnimation();
                    k.startAnimation(p);
                    o = 3;
                } else
                if(i.getBottom() < r + u && o != 2)
                {
                    j.setText(0x7f0a01fc);
                    if(o != 1)
                    {
                        k.clearAnimation();
                        k.startAnimation(q);
                    }
                    o = 2;
                }
            } else
            {
                k.setVisibility(8);
                i();
            }
        if(true) goto _L1; else goto _L3
_L3:
    }

    static boolean a(NPullToRefreshListView npulltorefreshlistview, boolean flag)
    {
        npulltorefreshlistview.x = flag;
        return flag;
    }

    static LinearLayout b(NPullToRefreshListView npulltorefreshlistview)
    {
        return npulltorefreshlistview.i;
    }

    private void b(MotionEvent motionevent)
    {
        int i1;
        int j1;
        i1 = 1;
        j1 = motionevent.getHistorySize();
        Object aobj[] = new Object[2];
        aobj[0] = Integer.valueOf(n);
        aobj[i1] = Integer.valueOf(o);
        Log.d("PullToRefreshListView", String.format("[applyHeaderPadding]currState=%d, refreshState=%d", aobj));
        int l2 = ((Integer)android.view.MotionEvent.class.getMethod("getPointerCount", new Class[0]).invoke(motionevent, new Object[0])).intValue();
        i1 = l2;
_L8:
        int k1 = 0;
_L6:
        int l1;
        if(k1 >= j1)
            break MISSING_BLOCK_LABEL_414;
        l1 = 0;
_L3:
        if(l1 >= i1)
            break MISSING_BLOCK_LABEL_408;
        if(o != 3) goto _L2; else goto _L1
_L1:
        if(isVerticalFadingEdgeEnabled())
            setVerticalScrollBarEnabled(false);
        int k2;
        class cls_aclass[] = new Class[2];
        aclass[0] = Integer.TYPE;
        aclass[1] = Integer.TYPE;
        Method method = android.view.MotionEvent.class.getMethod("getHistoricalY", aclass);
        Object aobj1[] = new Object[2];
        aobj1[0] = Integer.valueOf(l1);
        aobj1[1] = Integer.valueOf(k1);
        k2 = ((Float)method.invoke(motionevent, aobj1)).intValue();
        int i2 = k2;
_L4:
        int j2 = (int)((double)(i2 - t - r) / 1.7D);
        i.setPadding(i.getPaddingLeft(), j2, i.getPaddingRight(), i.getPaddingBottom());
_L2:
        l1++;
          goto _L3
        IllegalArgumentException illegalargumentexception1;
        illegalargumentexception1;
        throw illegalargumentexception1;
        IllegalAccessException illegalaccessexception1;
        illegalaccessexception1;
        System.err.println((new StringBuilder()).append("unexpected ").append(illegalaccessexception1).toString());
        continue; /* Loop/switch isn't completed */
        InvocationTargetException invocationtargetexception1;
        invocationtargetexception1;
        System.err.println((new StringBuilder()).append("unexpected ").append(invocationtargetexception1).toString());
        continue; /* Loop/switch isn't completed */
        NoSuchMethodException nosuchmethodexception1;
        nosuchmethodexception1;
        i2 = (int)motionevent.getHistoricalY(k1);
          goto _L4
        IllegalArgumentException illegalargumentexception;
        illegalargumentexception;
        throw illegalargumentexception;
        IllegalAccessException illegalaccessexception;
        illegalaccessexception;
        System.err.println((new StringBuilder()).append("unexpected ").append(illegalaccessexception).toString());
        i2 = 0;
          goto _L4
        InvocationTargetException invocationtargetexception;
        invocationtargetexception;
        System.err.println((new StringBuilder()).append("unexpected ").append(invocationtargetexception).toString());
        i2 = 0;
          goto _L4
        k1++;
        if(true) goto _L6; else goto _L5
_L5:
        return;
        NoSuchMethodException nosuchmethodexception;
        nosuchmethodexception;
        if(true) goto _L8; else goto _L7
_L7:
    }

    static int c(NPullToRefreshListView npulltorefreshlistview)
    {
        return npulltorefreshlistview.o;
    }

    private void h()
    {
        Object aobj[] = new Object[2];
        aobj[0] = Integer.valueOf(n);
        aobj[1] = Integer.valueOf(o);
        Log.d("PullToRefreshListView", String.format("[resetHeaderPadding]currState=%d, refreshState=%d", aobj));
        i.setPadding(i.getPaddingLeft(), s, i.getPaddingRight(), i.getPaddingBottom());
    }

    private void i()
    {
        if(o != 1)
        {
            o = 1;
            h();
            j.setText(0x7f0a01fe);
            j.setVisibility(0);
            k.setImageResource(0x7f02010c);
            k.clearAnimation();
            k.setVisibility(8);
            l.setVisibility(8);
        }
    }

    public void a()
    {
        setHeaderDividersEnabled(false);
        i.setVisibility(8);
        setDivider(null);
    }

    public void a(int i1)
    {
        u = i1;
    }

    public void a(cls_j j1)
    {
        f = j1;
    }

    public void a(String s1)
    {
        if(s1 != null)
        {
            m.setVisibility(0);
            m.setText(s1);
        } else
        {
            m.setVisibility(4);
        }
    }

    public void b()
    {
        i.setVisibility(0);
        setHeaderDividersEnabled(true);
    }

    public void b(String s1)
    {
        a(s1);
        f();
    }

    public void c()
    {
        setSelection(-1);
        d();
        e();
    }

    public void d()
    {
        h();
        k.setVisibility(8);
        k.setImageDrawable(null);
        l.setVisibility(0);
        j.setText(0x7f0a01fd);
        m.setVisibility(4);
        o = 4;
    }

    public void e()
    {
        if(f != null)
            f.a();
    }

    public void f()
    {
        i();
        if(i.getBottom() >= 0)
        {
            invalidateViews();
            setSelection(1);
        }
    }

    public void g()
    {
        i();
    }

    public int getSolidColor()
    {
        return super.getSolidColor();
    }

    protected void onAttachedToWindow()
    {
        super.onAttachedToWindow();
        Log.v("onAttachedTowindow", "onAttachedWindow is: running");
    }

    protected void onLayout(boolean flag, int i1, int j1, int k1, int l1)
    {
        super.onLayout(flag, i1, j1, k1, l1);
        Log.v("onLayout", "onLayout is ");
    }

    protected void onMeasure(int i1, int j1)
    {
        super.onMeasure(i1, j1);
        if(r <= 0)
            r = i.getMeasuredHeight();
    }

    public void onScroll(AbsListView abslistview, int i1, int j1, int k1)
    {
        if(n == 2 && i1 == 0 && o != 4)
            setSelection(1);
        if(g != null)
            g.onScroll(abslistview, i1, j1, k1);
    }

    public void onScrollStateChanged(AbsListView abslistview, int i1)
    {
        n = i1;
        if(g != null)
            g.onScrollStateChanged(abslistview, i1);
    }

    public boolean onTouchEvent(MotionEvent motionevent)
    {
        boolean flag = true;
        if(!x) goto _L2; else goto _L1
_L1:
        return flag;
_L2:
        int i1;
        Log.v("ONTOUCHEVNET", (new StringBuilder()).append("event.getAction() : ").append(motionevent.getAction()).toString());
        i1 = (int)motionevent.getY();
        0xff & motionevent.getAction();
        JVM INSTR tableswitch 0 2: default 84
    //                   0 214
    //                   1 93
    //                   2 223;
           goto _L3 _L4 _L5 _L6
_L6:
        break MISSING_BLOCK_LABEL_223;
_L3:
        break; /* Loop/switch isn't completed */
_L5:
        break; /* Loop/switch isn't completed */
_L8:
        flag = super.onTouchEvent(motionevent);
        if(true) goto _L1; else goto _L7
_L7:
        if(!isVerticalScrollBarEnabled())
            setVerticalScrollBarEnabled(flag);
        if(getFirstVisiblePosition() == 0 && o != 4)
            if((i.getBottom() >= r + u || i.getTop() >= 0) && o == 3)
            {
                o = 4;
                d();
                e();
            } else
            if(i.getBottom() < r + u || i.getTop() <= 0)
            {
                i();
                setSelection(flag);
            }
          goto _L8
_L4:
        t = i1;
          goto _L8
        a(motionevent);
        b(motionevent);
          goto _L8
    }

    public void setAdapter(Adapter adapter)
    {
        setAdapter((ListAdapter)adapter);
    }

    public void setAdapter(ListAdapter listadapter)
    {
        super.setAdapter(listadapter);
        setSelection(1);
    }

    public void setOnScrollListener(android.widget.AbsListView.OnScrollListener onscrolllistener)
    {
        g = onscrolllistener;
    }

    public void setSelection(int i1)
    {
        super.setSelection(i1);
        Log.v("NPULLTOREFRESHLISTVIEW", (new StringBuilder()).append("slection: position ").append(i1).toString());
    }

    private static final String a = "PullToRefreshListView";
    private static final int b = 1;
    private static final int c = 2;
    private static final int d = 3;
    private static final int e = 4;
    private cls_j f;
    private android.widget.AbsListView.OnScrollListener g;
    private LayoutInflater h;
    private LinearLayout i;
    private TextView j;
    private ImageView k;
    private ProgressBar l;
    private TextView m;
    private int n;
    private int o;
    private RotateAnimation p;
    private RotateAnimation q;
    private int r;
    private int s;
    private int t;
    private int u;
    private final int v;
    private bk w;
    private boolean x;
}
